package com.ruoyi.teacher.course.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.teacher.course.domain.Excellcourse;
import com.ruoyi.teacher.course.service.IExcellcourseService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 精品课程Controller
 * 
 * @author duanxinli
 * @date 2023-11-07
 */
@RestController
@RequestMapping("/courseteach/course")
public class ExcellcourseController extends BaseController
{
    @Autowired
    private IExcellcourseService excellcourseService;

    /**
     * 查询精品课程列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(Excellcourse excellcourse)
    {
        startPage();
        List<Excellcourse> list = excellcourseService.selectExcellcourseList(excellcourse);
        return getDataTable(list);
    }

    /**
     * 导出精品课程列表
     */
    @PreAuthorize("@ss.hasPermi('courseteach:course:export')")
    @Log(title = "精品课程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Excellcourse excellcourse)
    {
        List<Excellcourse> list = excellcourseService.selectExcellcourseList(excellcourse);
        ExcelUtil<Excellcourse> util = new ExcelUtil<Excellcourse>(Excellcourse.class);
        util.exportExcel(response, list, "精品课程数据");
    }

    /**
     * 获取精品课程详细信息
     */
    @Anonymous
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(excellcourseService.selectExcellcourseById(id));
    }

    /**
     * 新增精品课程
     */
    @PreAuthorize("@ss.hasPermi('courseteach:course:add')")
    @Log(title = "精品课程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Excellcourse excellcourse)
    {
        return toAjax(excellcourseService.insertExcellcourse(excellcourse));
    }

    /**
     * 修改精品课程
     */
    @PreAuthorize("@ss.hasPermi('courseteach:course:edit')")
    @Log(title = "精品课程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Excellcourse excellcourse)
    {
        return toAjax(excellcourseService.updateExcellcourse(excellcourse));
    }

    /**
     * 删除精品课程
     */
    @PreAuthorize("@ss.hasPermi('courseteach:course:remove')")
    @Log(title = "精品课程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(excellcourseService.deleteExcellcourseByIds(ids));
    }
}
